%===================================================================================================
%[]FUNCTION NAME: JulianDate.m
%[]AUTHOR: Julio C�sar Benavides
%[]CREATED: 12/06/2005
%[]REVISED: 05/03/2016
%===================================================================================================
%[]FUNCTION DESCRIPTION:
%This function calculates the equivalent Julian Day of a Gregorian coordinated universal time.
%===================================================================================================
%[]INPUT VARIABLES:
%(UTC)|Gregorian coordinated universal time expressed as a calendar date.
%===================================================================================================
%[]OUTPUT VARIABLES:
%(JD)|Equivalent Julian Date.
%===================================================================================================
%[]VARIABLE FORMAT:
%(UTC)|Row Vector {1 x 6}.
%---------------------------------------------------------------------------------------------------
%(JD)|Scalar {1 x 1}.
%===================================================================================================
%[]AUXILIARY FUNCTIONS:
%None.
%===================================================================================================
%[]COMMENTS:
%The equivalent Julian day is calculated to the exact second using the Boulet method.  The elements of the
%coordinated universal time (UTC) input vector should have the following format: UTC = [year, month,
%day, hour, minute, second].
%===================================================================================================
function JD = JulianDate(UTC)

year = UTC(1);
%[]Current year.

month = UTC(2);
%[]Current month.

day = UTC(3);
%[]Current day.

hour = UTC(4);
%[]Current hour.

minute = UTC(5);
%[]Current minute.

second = UTC(6);
%[]Current second.

Jo = 367 * year - fix(7 * (year + fix((month + 9) / 12)) / 4) + fix(275 * month / 9) + day + 1721013.5;
%[days]Julian day number at zero hour universal time.

UT = (hour + minute / 60 + second / 3600) / 24;
%[days]Universal time.

JD = Jo + UT;
%[days]Julian day number for desired universal time.

end
%===================================================================================================